Partial Class Controls_AddNewUser
    Inherits System.Web.UI.UserControl

    Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
        Dim p As ProfileCommon = ProfileCommon.Create(CreateUserWizard1.UserName, True)
        Dim objUser As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
        Roles.AddUserToRole(objUser.UserName, ViewState("Role"))
        p.FirstName = ViewState("FirstName").ToString()
        p.LastName = ViewState("LastName").ToString()
        p.ClientId = ViewState("ClientId")
        p.BranchId = ViewState("BranchId")
        p.Save()
    End Sub


    Protected Sub CreateUserWizard1_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles CreateUserWizard1.NextButtonClick
        If CreateUserWizard1.ActiveStep.ID = "UserProfile" Then
            Dim txtFirstname As TextBox = CType(CreateUserWizard1.ActiveStep.FindControl("txtFirstName"), TextBox)
            Dim txtLastName As TextBox = CType(CreateUserWizard1.ActiveStep.FindControl("txtLastName"), TextBox)
            Dim ddlRole As DropDownList = CType(CreateUserWizard1.ActiveStep.FindControl("ddlRole"), DropDownList)
            If Not (ddlRole.SelectedValue Is Nothing) Then
                ViewState("Role") = ddlRole.SelectedValue
            End If
            Dim ddlBranch As DropDownList = CType(CreateUserWizard1.ActiveStep.FindControl("ddlBranch"), DropDownList)
            If (ddlBranch.SelectedValue.Length > 0) Then
                ViewState("BranchId") = Convert.ToInt32(ddlBranch.SelectedValue)
            End If
            ViewState("FirstName") = txtFirstname.Text.ToString()
            ViewState("LastName") = txtLastName.Text.ToString()
            ViewState("ClientId") = Profile.ClientId
        End If
    End Sub
    Protected Sub ContinueButton_Click1(ByVal sender As Object, ByVal e As System.EventArgs)
        FormsAuthentication.SignOut()
        Response.Redirect("~/Login.aspx")
    End Sub
End Class
